package com.bj58.migrate.condition.reader;

import java.io.File;

import com.bj58.migrate.condition.ConditionReader;
import com.bj58.migrate.helper.Helper;

public class FanbaoConditionReader implements ConditionReader{

	public File[] getConditionFileList( String[] args ){

		if( args.length < 2 ){
			return null;
		}

		String num = args[ 2 ];

		File fbDirectory = Helper.seekFile( "fb" );
		if( fbDirectory.isDirectory() && fbDirectory.listFiles() != null ){
			int index = Integer.parseInt( num ) - 1;
			if( index >= fbDirectory.listFiles().length ){
				return null;
			}
			File[] runFile = fbDirectory.listFiles();
			for( File file : runFile ){
				if( file.getName().equals( "user" + num.trim() + ".txt" ) ){
					return new File[]{ file };
				}
			}
		}

		return null;
	}

}
